<head>
    <meta charset="UTF-8">
    <title>申请流程管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon"/>
    <link rel="stylesheet" href="../css/font.css">
    <link rel="stylesheet" href="../css/xadmin.css">
    <script type="text/javascript"
            src="../lib/vue/jquery.min.js"></script>
    <script type="text/javascript" src="../lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="../js/xadmin.js"></script>
    <script type="text/javascript" src="../js/global.js"></script>
    <script type="text/javascript" src="../js/store.js"></script>
    <script type="text/javascript" src="../js/cookies.js"></script>
    <script src="../lib/vue/vue.min.js"></script>
    <script src="../lib/vue/axios.min.js"></script>
</head>

<body class="layui-anim layui-anim-up" onload="checkLogin ()">
<div id="requestion">
    <div class="x-nav">
      <span class="layui-breadcrumb">
        <a href='javascript:parent.location.href="../index.html"'>申请流程管理</a>
        <a>
          <cite>申请列表</cite></a>
      </span>
        <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
           href="javascript:location.replace(location.href);" title="刷新">
            <i class="layui-icon" style="line-height:30px">ဂ</i></a>
    </div>
    <div class="x-body">
        <xblock>
            <div class="layui-row">
                <div class="layui-col-xs4 " v-show="userType == 1">
                    <button class="layui-btn" onclick="x_admin_show('添加申请单','./requestion-add.html',600,400)"><i
                            class="layui-icon"></i>添加申请单
                    </button>
                </div>
                <div class="layui-col-xs8">
                    <div class="layui-inline" style="width: 200px;">
                        <input id="searchKey" type="text" name="searchKey" placeholder="请输入组件名称关键字查询"
                               autocomplete="off" class="layui-input">
                    </div>
                    <button class="layui-btn" data-type="reload"><i
                            class="layui-icon">&#xe615;</i></button>
                </div>
            </div>
        </xblock>
        <table id="requestionList" lay-filter="requestionList"></table>
    </div>
    <input hidden id="editRequestion" value=""/>
</div>
<!--<script type="text/html" id="requestionBar">
    {{#  if(parseInt(getCookie('userType'))==1){ }}
    <a class="layui-btn layui-btn-xs" lay-event="requestionDetail">查看申请进度</a>
    &lt;!&ndash;<a class="layui-btn lay'usui-btn-danger layui-btn-xs" lay-even lay-event="delete">删除</a>&ndash;&gt;
    {{#  }else if(parseInt(getCookie('userType'))==2&&vm.handingResult==0){ }}
    <a class="layui-btn layui-btn-xs" lay-event="examine">点击审批</a>
    {{#  }else if(parseInt(getCookie('userType'))==2){ }}
    <a class="layui-btn layui-btn-xs" lay-event="requestionDetail">查看申请进度</a>
    {{#  }else{ }}
    <a style="color: gray">无操作权限</a>
    {{# } }}
</script>-->
<script type="text/html" id="requestionBar">
    <a class="layui-btn layui-btn-xs" lay-event="requestionDetail">查看申请进度</a>
    {{# if(d.checked){ }}
    <a class="layui-btn layui-btn-xs" lay-event="examine">点击审批</a>
    {{# } }}
</script>
<script type="text/html" id="status">
    {{#  if(d.status == 0){ }}
    <a style="color: yellow">申请中</a>
    {{#  } else if(d.status == 1){ }}
    <a style="color: green">申请通过</a>
    {{#  } else { }}
    <a style="color: red">申请失败</a>
    {{#  } }}
</script>
<script>
    layui.use(['table', 'upload'], function () {
        var table = layui.table
        var upload = layui.upload;
        var sysId;
        if (isNaN(parseInt(getCookie("sysId")))) {
            sysId = null;
        } else {
            sysId = parseInt(getCookie("sysId"))
        }
        //第一个实例
        var environmentTable = table.render({
            elem: '#requestionList'
            , url: _hostUrl + '/cmsApplicationForms/page' //数据接口
            , where: {
                sysId: sysId
            }
            , page: true //开启分页
            , cols: [[ //表头
                {field: 'companyName', title: '公司名称', width: 160, align: 'center'},
                {field: 'sysName', title: '系统名称', width: 160, align: 'center'},
                {field: 'requestUserName', title: '申请人', width: 160, align: 'center'},
                {field: 'componentName', title: '申请接入组件', width: 160, align: 'center'},
                {field: 'requestTime', title: '申请时间', width: 160, align: 'center'},
                {field: 'status', title: '申请状态', width: 160, align: 'center', templet: '#status'},
                {title: '操作', align: 'center', toolbar: '#requestionBar'}
            ]], request: {
                pageName: 'pageIndex' //页码的参数名称，默认：page
                , limitName: 'pageSize' //每页数据量的参数名，默认：limit
            }
            , response: {
                statusName: 'responseCode' //数据状态的字段名称，默认：code
                , statusCode: 200 //成功的状态码，默认：0
                , msgName: 'responseMsg' //状态信息的字段名称，默认：msg
                , rootName: 'data'
                , countName: 'totalRecord'
                , dataName: 'resultList'
            },
        })

        //加入搜索功能
        var $ = layui.$, active = {
            reload: function () {
                environmentTable.reload({
                    where: {
                        sysId: sysId,
                        componentName: $("#searchKey").val()
                    }
                })
            }
        };
        $('.layui-col-xs8 .layui-btn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
        //监听工具条
        table.on('tool(requestionList)', function (obj) {
            var data = obj.data;
            if (obj.event === 'requestionDetail') {
                $("#editRequestion").val(JSON.stringify(data))
                x_admin_show('申请进度', './requestion-detail.html', 600, 450)
            } else if (obj.event === 'examine') {
                $("#editRequestion").val(JSON.stringify(data))
                x_admin_show('申请审核', './examine-edit.html', 600, 450);
            }
        })
    })
</script>
<script>
    let vm = new Vue({
        el: '#requestion',
        data() {
            return {
                userType: 0,
            }
        },
        //渲染之前加载cookie数据
        beforeMount() {
            this.userType = getCookie('userType')
        }
    })
</script>
</body>

